package com.itheima.userdemo.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

// 观察者
// 观察会话的创建与销毁
@WebListener
public class UserSessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("一个session创建了");
        HttpSession session = se.getSession();
        System.out.println("当前sessionId:"+session.getId());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("一个session销毁了");
    }
}
